package com.example.administrator.sunstart_library;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * 作者： 孙浩
 * 创建时间： 2017年04月08日16:42
 * 联系方式 QQ：243280864
 * 类注释：
 */

public class pop_list_adapter extends BaseAdapter {
    private List<MenuPopBean> data;
    private Context context;

    public pop_list_adapter(List<MenuPopBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        TextView tv = new TextView(context);
        tv.setPadding(20,20,20,20);
        Drawable drawable = context.getResources().getDrawable(data.get(i).getId());
        drawable.setBounds(0,0,drawable.getMinimumWidth(),drawable.getMinimumHeight());
        tv.setCompoundDrawablePadding(20);
        tv.setCompoundDrawables(drawable,null,null,null);
        tv.setText(data.get(i).getName());
        tv.setTextColor(context.getResources().getColor(R.color.white));
        return tv;
    }
}
